#include "decoder.h"

#include <errno.h>

#include <sys/stat.h>
#include <string.h>

#include <iostream>
#include <fstream>
using namespace std;

int main(int argc, char** argv)
{

	decoder dc;

	//string key = argv[1];

	/*
	unsigned char x = 101;
	key[0] = x;

	x = 254;
	key[1] = x;

	x = 3;
	key[44] = x;*/

	//dc.decrypt("/home/willion/Downloads/ciphertext2", argv[1],  atoi(argv[2]));
	//dc.decrypt("/home/willion/Downloads/ciphertext2", "EJACSisRESPONSIBLEfOrINCREASEDcarboNEMISSIONS",  45);
	//int num = atoi(argv[1]);
	//int thre = atoi(argv[2]);

	//dc.show_coin("/home/willion/Downloads/ciphertext2", 3, 5);

	dc.guess_ascill_key("/home/willion/Downloads/ciphertext2", 45);


	//cout <<(dc.demap('a', 'x')) <<endl;

	/*
	string plaintex = "the";
	plaintex += "and";
	plaintex += "for";
	plaintex += "are";
	plaintex += "but";
	plaintex += "not";
	plaintex += "you";
	plaintex += "all";
	plaintex += "any";
	plaintex += "can";
	plaintex += "had";
	plaintex += "her";
	plaintex += "was";
	plaintex += "one";
	plaintex += "our";
	plaintex += "out";
	plaintex += "day";
	plaintex += "get";
	plaintex += "has";
	plaintex += "him";
	plaintex += "his";
	plaintex += "how";
	plaintex += "man";
	plaintex += "new";
	plaintex += "now";
	plaintex += "old";
	plaintex += "see";
	plaintex += "two";
	plaintex += "way";
	plaintex += "who";
	plaintex += "boy";
	plaintex += "did";
	plaintex += "its";
	plaintex += "let";
	plaintex += "put";
	plaintex += "say";
	plaintex += "she";
	plaintex += "too";
	plaintex += "use";


	dc.plaintext_attack("/home/willion/Downloads/ciphertext2", 2414301, 3, plaintex);
*/
	//dc.show_coin("/home/willion/Downloads/ciphertext", 3, 5);

	//dc.show_key("/home/willion/Downloads/ciphertext2", 15);

	//dc.self_sub("/home/willion/Downloads/ciphertext2", 10);

	//dc.show_coin("/home/willion/Downloads/ciphertext", 3, 5);

	//cout <<db.com_sta("/home/willion/Downloads/ciphertext", 0.067, 0.0385) <<endl;

	/*
	dc.db.create_table_phase2("test");

	dc.db.insert_table_phase2("test", 0xa, 2);
	dc.db.insert_table_phase2("test", 0xa, 2);

	dc.db.insert_table_phase2("test", 0xa, 4);
	dc.db.insert_table_phase2("test", 0xa, 2);
	dc.db.insert_table_phase2("test", 0xa, 2);
	dc.db.insert_table_phase2("test", 0xa, 2);
	dc.db.insert_table_phase2("test", 0x8, 1);
	dc.db.insert_table_phase2("test", 0x8, 2);
	dc.db.insert_table_phase2("test", 0x9, 0);
	dc.db.insert_table_phase2("test", 0xa, 2);
	*/

/*
	db.insert("xyz", 263);
	db.insert("abc", 3);
	db.insert("abc", 4);
	db.insert("abc", 5);
	db.insert("xyz", 233);
	db.insert("xyz", 1024);
	db.insert("xyz", 1024323);
	db.insert("xyz", 1024222);
	db.insert("xyz", -123);
	db.insert("xyz", 0);

	db.show(7);
*/

	/*
	fstream infile;

	infile.open("/home/willion/Downloads/ciphertext", ios::out|ios::in);

	if (infile.good() == false)
	{
		exit(-1);
	}
	*/


	/*
	char buffer[4097];
	memset(buffer, 0, 4097);

	infile.read(buffer, 4096);

	int count = infile.gcount();

	for (int i = 0; i < (count - 3) + 1; i++)
	{
		db.insert_comb(buffer + i, i, 3);

	}

	infile.close();
	*/

	//db.show_coin(3, 5);
	//cout <<db.com_sta(0.067, 0.0385) <<endl;

	//struct stat st;
	//stat("/home/willion/Downloads/ciphertext", &st);

	//db.com_sta(0.067, 0.0385, st->st_size, )

}

